<template>
    <view>
		<view class="title">请上传清晰的一卡通照片进行身份认证</view>

  <view class="photo">
	   <image :src="changeImg" class="Img"></image>
<!-- 	    <image src="../../static/头像.jpg" class="Img"></image> -->
 </view>
  <view>
   <button class="but" type="primary" :loading="loading" :disabled="disabled" @click="upload">选择照片</button>
  </view>
 </view>
 
</template>

<script>
export default {
 data(){
	 return{
		 percent:0,
		 loading:false,
		 disabled:false,
		 changeImg:'',
	 }
 },
 methods : {
  upload : function(){
	  let that=this
   uni.chooseImage({
    count: 1,
    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
    sourceType: ['album'], //从相册选择
    success: function (res) {
     const tempFilePaths = res.tempFilePaths;//本地路径
	 console.log('本地路径',tempFilePaths);
	 that.changeImg = tempFilePaths[0];
	 console.log('changImg', that.changeImg);
     const uploadTask = uni.uploadFile({
     // url : 'https://demo.hcoder.net/index.php?c=uperTest',
	  url:'https://hotenergy.club/workapp/auth',
      filePath: tempFilePaths[0],
      name: 'file',
 	  header:{"Content-Type": "multipart/form-data"},
	 /* formData:{}, 
	  success: (res) => {
		  console.log(res)
	  	if (res.data.code == 200){
	  	            console.log('文件上传成功')
	  	 }
		 
	  }*/
      success: function (uploadFileRes) {
		console.log(uploadFileRes)
       console.log('后台',uploadFileRes.data);
      }
     });
 
/*     uploadTask.onProgressUpdate(function (res) {
      _self.percent = res.progress;
      console.log('上传进度' + res.progress);
      console.log('已经上传的数据长度' + res.totalBytesSent);
      console.log('预期需要上传的数据总长度' + res.totalBytesExpectedToSend);
     }); */
    },
    error : function(e){
     console.log('错误',e);
    }
   });
  }
 },
    onLoad:function(){
  
    }
}
</script>

<style>
.title{
	margin-top: 30rpx;	
	display: flex;
	justify-content: center;
}
.photo{
	height: 400rpx;
	margin: 30rpx 25rpx 50rpx 25rpx;
	border-radius: 25rpx;
	border: 1px solid #e6e6e6; 
	background-color:#e6e6e6 ; 
}
.ima{
	height: 80rpx;
	width: 80rpx;
	margin: 160rpx  0 0 310rpx;
}
.but{
	width: 400rpx;
	background-color: #666FFC !important;
}
.Img{
	height: 400rpx;
	width: 700rpx;
	border-radius: 25rpx;
}
</style>
